// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//
#pragma once

#include <pollux/exec/aggregate.h>
#include <pollux/testing/exec/aggregation_fuzzer_base.h>
#include <pollux/plan/reference_query_runner.h>
#include <pollux/vector/vector_fuzzer.h>

using namespace kumo::pollux::plan;

namespace kumo::pollux::exec::test {
    /// Runs the aggregation fuzzer.
    /// @param signatureMap Map of all aggregate function signatures.
    /// @param seed Random seed - Pass the same seed for reproducibility.
    /// @param orderDependentFunctions Map of functions that depend on order of
    /// input.
    /// @param orderableGroupKeys Whether group keys must be orderable or be just
    /// comparable.
    /// @param functionDataSpec Mapping of function and their input data spec.
    /// @param planPath Path to persisted plan information. If this is
    /// supplied, fuzzer will only verify the plans.
    /// @param referenceQueryRunner Reference query runner for results
    /// verification.
    void aggregateFuzzer(
        AggregateFunctionSignatureMap signatureMap,
        size_t seed,
        const std::unordered_set<std::string> &functionsRequireSortedInput,
        const std::unordered_map<std::string, std::shared_ptr<ResultVerifier> > &
        orderDependentFunctions,
        const std::unordered_map<std::string, std::shared_ptr<InputGenerator> > &
        customInputGenerators,
        const std::unordered_map<std::string, DataSpec> &functionDataSpec,
        VectorFuzzer::Options::TimestampPrecision timestampPrecision,
        const std::unordered_map<std::string, std::string> &queryConfigs,
        const std::unordered_map<std::string, std::string> &hiveConfigs,
        bool orderableGroupKeys,
        const std::optional<std::string> &planPath,
        std::unique_ptr<ReferenceQueryRunner> referenceQueryRunner);
} // namespace kumo::pollux::exec::test
